package com.media.themovieworld.activity;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;

import com.media.themovieworld.Config;
import com.media.themovieworld.model.ObServerListener;
import com.media.themovieworld.player.MoviePlayerActivity;
import com.media.themovieworld.screen.main.MainScreen;
import com.media.themovieworld.screen.menu.LeftMenuScreen;
import com.media.themovieworld.util.FacebookUtils;

public class MainActivity extends SlidingFragmentActivity{

	private MainScreen mMainScreen;
	private ObServerListener mObServerListener;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mMainScreen = new MainScreen();
		switchMenu(new LeftMenuScreen(), false);
		switchContent(mMainScreen, false);
	}
	
	@Override
	public void onConfigurationChanged(Configuration newConfig) {
	    super.onConfigurationChanged(newConfig);

	    // Checks the orientation of the screen
	    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
//	        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
	    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
//	        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
	    }
	}
	
	public void update(){
		if (mMainScreen!=null) {
			mMainScreen.update();
		}
	}
	
	public MainScreen getMainScreen(){
		return mMainScreen;
	}
	
	public void startMoviePlayerActivity(){
		startActivity(new Intent(getApplicationContext(), MoviePlayerActivity.class));
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		FacebookUtils.onActivityResult(this, requestCode, resultCode, data);
	}
}
